package com.ctrip.study.algorithm.recursion;

import junit.framework.TestCase;

import org.junit.Test;

/**
 * 汉诺塔问题.
 */
public class Towers extends TestCase{
	
	private static int nDisk = 3;
	
	private void doTower(int num, char from, char inter, char to){
		if(num == 1){
			System.out.println("Move Disk1 from " + from + " to " + to);
		}else{
			doTower(num - 1, from, to, inter);
			System.out.println("Move Disk" + num + " from " + from + " to " + to);
			doTower(num - 1, inter, from, to);
		}
	}
	
	@Test
	public void test(){
		doTower(nDisk, 'A', 'B', 'C');
	}

}
